<template>
  <div class="box1">
    姓名: <input type="text" v-model="name" /> <br /><br />
    年龄: <input type="text" v-model="age" /> <br /><br />
    身高: <input type="text" v-model.number="h" /> <br /><br />
    体重: <input type="text" v-model.number="w" /> <br /><br />
    病史: <input type="text" v-model="b" /> <br /><br />
    <button @click="look">诊断</button><br /><br />

    这位病友{{ name }} 你有大病 {{ kk }}
  </div>
</template>
<script>
export default {
  name: 'MainCom',
  data () {
    return {
      name: '',
      age: '',
      h: '',
      w: '',
      b: '',
      kk: ''
    }
  },
  created () {
  },
  computed: {
    bim () {
      return this.w / (this.h ^ 2)
    }
  },
  methods: {
    look () {

      if (this.bim <= 18.5) {
        return this.kk = '体重过轻'
      } else if (this.bim <= 24.9) {
        return this.kk = '正常'
      } else if (this.bim <= 29.9) {
        return this.kk = '体重过重'
      } else {
        return this.kk = '肥胖'
      }
    }
  }
}
</script>
<style lang='less'  scoped>
.box1 {
  padding: 20px;
}
</style>
